package com.lame.sbconstant.product.strategy;

import com.lame.detect.vo.ClassMeta;
import com.lame.sbconstant.product.vo.ProductDesc;
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.tree.ParseTree;

public class DfDaoStrategy extends ProductActorAdapter {

    private String tpl = "${PACKAGE}.mapper;\n"+
            "import ${BASE_PKG}.entity.${ENTITY};\n"+
              "import com.baomidou.mybatisplus.core.conditions.Wrapper;\n" +
            "import com.baomidou.mybatisplus.core.mapper.BaseMapper;\n" +
            "import com.baomidou.mybatisplus.core.metadata.IPage;\n" +
            "import com.baomidou.mybatisplus.extension.plugins.pagination.Page;\n" +
            "import org.apache.ibatis.annotations.Param;\n" +
            "import org.apache.ibatis.annotations.Select;\n" +
                      "public interface ${ENTITY}Mapper extends BaseMapper<${ENTITY}> {\n" +
                      "}\n";


    @Override
    public String product(Parser parser, ParseTree parseTree, ClassMeta classMeta) {
        return TplTools.generate(classMeta, tpl);
    }

    @Override
    public ProductDesc productDesc(Parser parser, ParseTree parseTree, ClassMeta classMeta) {
        final String generate = TplTools.generate(classMeta, tpl);
        return new ProductDesc("./mapper/" + classMeta.getName() + "Mapper.java", generate, false);
    }
}
